package utils.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

import entity.MunicipalUnitsTitleEntity;
import fragment.menufragments.MunicipalUnitsSingotenFragment;

/**
 * Created by dllo on 15/12/3.
 */
public class MunicipalUnitsTitleAdapter extends FragmentStatePagerAdapter {
    private List<MunicipalUnitsTitleEntity.ResultEntity> list = null;

    public void setList(List<MunicipalUnitsTitleEntity.ResultEntity> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    public MunicipalUnitsTitleAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        long code = list.get(position).getProvinceCode();
        return MunicipalUnitsSingotenFragment.getInstance(code);
    }

    @Override
    public int getCount() {
        return list != null && list.size()>0?list.size():0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position).getProvinceName();
    }
}
